package com.eastcom.bm.service.impl;

import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;

import com.eastcom.bm.atom.Atom_DatasetDefine;
import com.eastcom.bm.dao.DAOFactory;
import com.eastcom.bm.dao.IDataSetDao;
import com.eastcom.bm.service.IDataSetService;
import com.eastcom.bm.service.IRawDataService;
import com.eastcom.canicula.stope.utils.DateUtil;
import com.eastcom.common.db.DataSourceFactory;
import com.eastcom.common.db.JDBCTemplate;
import com.eastcom.providor.BMSetting;


public class DataSetService implements IDataSetService{

	private static Logger log = BMSetting.getBMlog();
	
	public List<Atom_DatasetDefine> getAllDatasetDefine() {
		try{
			IDataSetDao dataSetDao=DAOFactory.getInstance().getDataSetDao();
			return dataSetDao.getAllDataSetDefine();
		}
		catch(Exception e){
			log.error("IDataSetService getAllAtom_KpiDefine error", e);
		}
		
		finally{
			JDBCTemplate.doSessionFinally();
		}
		
		return null;
	}

	public Atom_DatasetDefine findDatasetDefineById(String id) {
		try{
			IDataSetDao dataSetDao=DAOFactory.getInstance().getDataSetDao();
			return dataSetDao.findDatasetDefineById(id);
		}
		catch(Exception e){
			log.error("IDataSetService findDatasetDefineById error", e);
		}
		finally{
			JDBCTemplate.doSessionFinally();
		}
		
		return null;
	}
	
	public static void main(String[] args){
		Date stDate=null,enDate=null;
		try {
			DataSourceFactory.initial();
			stDate=DateUtil.StringToDate("yyyy-MM-dd HH:mm:ss","2011-3-3 2:00:00");
			enDate=DateUtil.StringToDate("yyyy-MM-dd HH:mm:ss","2011-3-3 3:00:00");
		} 
		catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		IRawDataService raw=new RawDataService();
		List list=raw.getRawDatasByDataSetId("PPM_SC_HOUR", stDate, enDate);
		//DataSetService ser=new DataSetService();
		//list=ser.getAllDatasetNode("");
		list.size();
		DataSourceFactory.getInstance().destory();
	}
	
}
